// 采购记录
var procColumns = [{
  id: 'no',
  title: '序号',
  width: 45,
  type: 'string',
  columnClass: 'text-center',
},{
  id: 'list',
  title: '资产类目',
  width: 73,
  type: 'string',
  columnClass: 'text-center',
}, {
  id: 'type',
  title: '资产类别',
  width: 73,
  type: 'string',
  columnClass: 'text-center',
}, {
  id: 'size',
  title: '数量',
  width: 100,
  type: 'string',
  columnClass: 'text-center',
}, {
  id: 'price',
  title: '预计金额',
  width: 150,
  type: 'string',
  columnClass: 'text-center',
}, {
  id: 'msg',
  title: '资产描述',
  type: 'string',
  columnClass: 'text-left',
},];
var procOption = {
  lang: 'zh-cn',
  ajaxLoad: false,
  // loadURL:'url',
  exportFileName: '资产信息',
  datas: [{
    no: '1',
    list: '硬件',
    type: '笔记本',
    size: '999999999',
    price: '￥999,999,999.99元',
    msg: '资产描述测试数据',
  }, ],
  columns: procColumns,
  gridContainer: 'procContainer',
  toolbarContainer: 'procToolBarContainer',
  tools: '',
  pageSize: 10,
  pageSizeLimit: [10, 15, 20]
};
var procGrid = $.fn.dlshouwen.grid.init(procOption);
$(function () {
  procGrid.load();
});

// 资产库记录
var libraryColumns = [
  {
    id: 'number',
    title: '序号',
    width: 45,
    type: 'string',
    columnClass: 'text-center',
  },{
  id: 'list',
  title: '资产类目',
  width: 73,
  type: 'string',
  columnClass: 'text-center',
}, {
  id: 'type',
  title: '资产类别',
  width: 73,
  type: 'string',
  columnClass: 'text-center',
}, {
  id: 'no',
  title: '资产编号',
  width: 170,
  type: 'string',
  columnClass: 'text-center',
}, {
  id: 'msg',
  title: '资产描述',
  type: 'string',
  columnClass: 'text-left',
},{
  id: 'status',
  title: '状态',
  width: 75,
  type: 'string',
  columnClass: 'text-center',
},{
  id: 'gname',
  title: '归属人',
  width: 75,
  type: 'string',
  columnClass: 'text-center',
}, {
  id: 'gpro',
  title: '归属项目',
  width: 75,
  type: 'string',
  columnClass: 'text-center',
}, {
  id: 'address',
  title: '放置地',
  width: 75,
  type: 'string',
  columnClass: 'text-center',
},];
var libraryOption = {
  lang: 'zh-cn',
  ajaxLoad: false,
  // loadURL:'url',
  exportFileName: '资产库借货信息',
  datas: [{
    id: 1,
    number: '1',
    no: 'NJSTS20180102180222',
    list: '硬件',
    type: '笔记本',
    msg: '资产描述测试数据',
    status: '闲置',
    gname: '张三',
    gpro:'',
    address: '南京'
  }, ],
  columns: libraryColumns,
  gridContainer: 'libraryContainer',
  toolbarContainer: 'libraryToolBarContainer',
  tools: '',
  pageSize: 10,
  pageSizeLimit: [10, 15, 20]
};
var libraryGrid = $.fn.dlshouwen.grid.init(libraryOption);
$(function () {
  libraryGrid.load();
});


// 结果清单
var endColumns = [
  {
    id: 'number',
    title: '序号',
    width: 45,
    type: 'string',
    columnClass: 'text-center',
  },{
  id: 'list',
  title: '资产类目',
  width: 73,
  type: 'string',
  columnClass: 'text-center',
}, {
  id: 'type',
  title: '资产类别',
  width: 73,
  type: 'string',
  columnClass: 'text-center',
}, {
  id: 'no',
  title: '资产编号',
  width: 170,
  type: 'string',
  columnClass: 'text-center',
}, {
  id: 'msg',
  title: '资产描述',
  type: 'string',
  columnClass: 'text-left',
},{
  id: 'status',
  title: '状态',
  width: 75,
  type: 'string',
  columnClass: 'text-center',
},{
  id: 'gname',
  title: '归属人',
  width: 75,
  type: 'string',
  columnClass: 'text-center',
},{
  id: 'gpro',
  title: '归属项目',
  width: 75,
  type: 'string',
  columnClass: 'text-center',
}, {
  id: 'address',
  title: '放置地',
  width: 75,
  type: 'string',
  columnClass: 'text-center',
},{
  id: 'operation',
  title: '操作',
  width: 60,
  type: 'string',
  columnClass: 'text-center',
  resolution: function (value, record, column, grid, dataNo, columnNo) {
    var content = '';
    content += '<button class="btn btn-xs btn-success" onclick="editast(' + record.id + ');"><i class="fa fa-edit"></i>  办理</button>';
    // content += '  ';
    // content += '<button class="btn btn-xs btn-primary" onclick="selast(' + record.id + ');"><i class="icon-eye-open"></i>  查看</button>';
    return content;
  }
}];
var endOption = {
  lang: 'zh-cn',
  ajaxLoad: false,
  // loadURL:'url',
  exportFileName: '结果清单',
  datas: [{
    id: 1,
    number: '1',
    no: 'NJSTS20180102180222',
    list: '硬件',
    type: '笔记本',
    msg: '资产描述测试数据',
    status: '闲置',
    gname: '',
    gpro: '中国移动',
    address: '南京'
  }, ],
  columns: endColumns,
  gridContainer: 'endContainer',
  toolbarContainer: 'endToolBarContainer',
  tools: '',
  pageSize: 10,
  pageSizeLimit: [10, 15, 20]
};
var endGrid = $.fn.dlshouwen.grid.init(endOption);
$(function () {
  endGrid.load();
});

// 资产办理
function editast(id) {
  window.location.href = "../../proinfo/edit/edit-assets-2.html" + '?id=' + id;
}

// 采购记录
var proc1Columns = [{
  id: 'no',
  title: '序号',
  width: 45,
  type: 'string',
  columnClass: 'text-center',
}, {
  id: 'list',
  title: '类目',
  width: 73,
  type: 'string',
  columnClass: 'text-center',
}, {
  id: 'type',
  title: '类别',
  width: 73,
  type: 'string',
  columnClass: 'text-center',
}, {
  id: 'name',
  title: '名称',
  width: 73,
  type: 'string',
  columnClass: 'text-center',
}, {
  id: 'nmsg',
  title: '品名及规格',
  width: 200,
  type: 'string',
  columnClass: 'text-left',
}, {
  id: 'size',
  title: '数量',
  width: 100,
  type: 'string',
  columnClass: 'text-center',
}, {
  id: 'price',
  title: '预计金额',
  width: 150,
  type: 'string',
  columnClass: 'text-center',
}, {
  id: 'msg',
  title: '备注',
  type: 'string',
  columnClass: 'text-left',
},{
  id: 'operation',
  title: '操作',
  width: 130,
  type: 'string',
  columnClass: 'text-center',
  resolution: function (value, record, column, grid, dataNo, columnNo) {
    var content = '';
    content += '<button class="btn btn-xs btn-info" onclick=""><i class="fa fa-edit"></i>  编辑</button>';
    content += '  ';
    content += '<button class="btn btn-xs btn-danger" onclick="del(' + record.id + ');"><i class="fa fa-trash-o"></i>  删除</button>';
    return content;
  }
}];
var proc1Option = {
  lang: 'zh-cn',
  ajaxLoad: false,
  // loadURL:'url',
  exportFileName: '资产信息',
  datas: [{
    no: '1',
    list: '硬件',
    type: '笔记本',
    name: '华硕办公笔记本',
    nmsg: 'i5CPU 8G内存 256内存',
    size: '999999999',
    price: '￥999,999,999.99元',
    msg: '备注测试数据',
  }, ],
  columns: proc1Columns,
  gridContainer: 'proc1Container',
  toolbarContainer: 'proc1ToolBarContainer',
  tools: '',
  pageSize: 10,
  pageSizeLimit: [10, 15, 20]
};
var proc1Grid = $.fn.dlshouwen.grid.init(proc1Option);
$(function () {
  proc1Grid.load();
});

// 资产库借货记录
var library1Columns = [{
  id: 'number',
  title: '序号',
  width: 45,
  type: 'string',
  columnClass: 'text-center',
}, {
  id: 'list',
  title: '资产类目',
  width: 73,
  type: 'string',
  columnClass: 'text-center',
}, {
  id: 'type',
  title: '资产类别',
  width: 73,
  type: 'string',
  columnClass: 'text-center',
}, {
  id: 'no',
  title: '资产编号',
  width: 170,
  type: 'string',
  columnClass: 'text-center',
}, {
  id: 'msg',
  title: '资产描述',
  type: 'string',
  columnClass: 'text-left',
},{
  id: 'status',
  title: '状态',
  width: 75,
  type: 'string',
  columnClass: 'text-center',
},{
  id: 'gname',
  title: '归属人',
  width: 75,
  type: 'string',
  columnClass: 'text-center',
}, {
  id: 'gpro',
  title: '归属项目',
  width: 75,
  type: 'string',
  columnClass: 'text-center',
}, {
  id: 'address',
  title: '放置地',
  width: 75,
  type: 'string',
  columnClass: 'text-center',
},{
  id: 'operation',
  title: '操作',
  width: 50,
  type: 'string',
  columnClass: 'text-center',
  resolution: function (value, record, column, grid, dataNo, columnNo) {
    var content = '';
    content += '<button class="btn btn-xs btn-danger" onclick="del(' + record.id + ');"><i class="fa fa-trash-o"></i>  删除</button>';
    return content;
  }
} ];
var library1Option = {
  lang: 'zh-cn',
  ajaxLoad: false,
  // loadURL:'url',
  exportFileName: '资产库借货信息',
  datas: [{
    id: 1,
    number: '1',
    no: 'NJSTS20180102180222',
    list: '硬件',
    type: '笔记本',
    msg: '资产描述测试数据',
    status: '闲置',
    gname: '张三',
    gpro: '中国移动',
    address: '南京'
  }, ],
  columns: library1Columns,
  gridContainer: 'library1Container',
  toolbarContainer: 'library1ToolBarContainer',
  tools: '',
  pageSize: 10,
  pageSizeLimit: [10, 15, 20]
};
var library1Grid = $.fn.dlshouwen.grid.init(library1Option);
$(function () {
  library1Grid.load();
});

// 借货记录
var lendColumns = [{
  id: 'username',
  title: '申请人',
  width: 73,
  type: 'string',
  columnClass: 'text-center',
}, {
  id: 'time',
  title: '申请时间',
  width: 73,
  type: 'string',
  columnClass: 'text-center',
}, {
  id: 'type',
  title: '申请用途',
  width: 73,
  type: 'string',
  columnClass: 'text-center',
}, {
  id: 'msg',
  title: '申请说明',
  type: 'string',
  columnClass: 'text-left',
},{
  id: 'operation',
  title: '操作',
  width: 50,
  type: 'string',
  columnClass: 'text-center',
  resolution: function (value, record, column, grid, dataNo, columnNo) {
    var content = '';
    content += '<button class="btn btn-xs btn-primary" onclick="selast(' + record.id + ');"><i class="icon-eye-open"></i>  查看</button>';
    return content;
  }
}];
var lendOption = {
  lang: 'zh-cn',
  ajaxLoad: false,
  // loadURL:'url',
  exportFileName: '借货记录',
  datas: [{
    username: '张三',
    type: '商用自用',
    time: '2018/01/02',
    msg: '申请说明测试数据'
  }, ],
  columns: lendColumns,
  gridContainer: 'lendContainer',
  toolbarContainer: 'lendToolBarContainer',
  tools: '',
  pageSize: 10,
  pageSizeLimit: [10, 15, 20]
};
var lendGrid = $.fn.dlshouwen.grid.init(lendOption);
$(function () {
  lendGrid.load();
});

//采购借货申请信息
function selast(id){
  window.location.href = "../../proinfo/edit/edit-assets-4.html" + '?id=' + id;
}

// 显示隐藏采购表单
function shproc(){
  $('.hdproc').show();
}

function hdproc(){
  $('.hdproc').hide();
}

// 资产库可用资产信息
var lidColumns = [{
  id: 'no',
  title: '资产编号',
  width: 170,
  type: 'string',
  columnClass: 'text-center',
},{
  id: 'address',
  title: '放置地',
  width: 73,
  type: 'string',
  columnClass: 'text-center',
},{
  id: 'msg',
  title: '资产描述',
  type: 'string',
  columnClass: 'text-left',
}, {
  id: 'operation',
  title: '操作',
  width: 50,
  type: 'string',
  columnClass: 'text-center',
  resolution: function (value, record, column, grid, dataNo, columnNo) {
    var content = '';
    content += '<button class="btn btn-xs btn-info" onclick="borrow(' + record.id + ');"><i class="icon-hand-right"></i>  申请</button>';
    return content;
  }
}];
var lidOption = {
  lang: 'zh-cn',
  ajaxLoad: false,
  // loadURL:'url',
  exportFileName: '资产库可用资产信息',
  datas: [{
    no: 'NJSTS20190102123111',
    gname: '张三',
    address: '南京',
    msg: '资产描述测试数据'
  }, ],
  columns: lidColumns,
  gridContainer: 'lidContainer',
  toolbarContainer: 'lidToolBarContainer',
  tools: '',
  pageSize: 10,
  pageSizeLimit: [10, 15, 20]
};
var lidGrid = $.fn.dlshouwen.grid.init(lidOption);
$(function () {
  lidGrid.load();
});

// 借货申请
function borrow(id){
  layer.confirm('是否确认申请此资源？', {
    title: '提示信息',
    btn: ['确认', '取消'] //按钮
  }, function () {
    layer.msg('申请成功', {
      icon: 1
    });
  });
}


var priceColumns = [{
  id: 'no',
  title: '序号',
  width: 50,
  type: 'string',
  columnClass: 'text-center',
}, {
  id: 'list',
  title: '类目',
  width: 74,
  type: 'string',
  columnClass: 'text-center',
}, {
  id: 'type',
  title: '类别',
  width: 74,
  type: 'string',
  columnClass: 'text-center',
}, {
  id: 'name',
  title: '名称',
  width: 74,
  type: 'string',
  columnClass: 'text-center',
}, {
  id: 'nmsg',
  title: '品名及规格',
  width: 200,
  type: 'string',
  columnClass: 'text-left',
}, {
  id: 'size',
  title: '数量',
  width: 100,
  type: 'string',
  columnClass: 'text-center',
}, {
  id: 'price',
  title: '预计金额',
  width: 150,
  type: 'string',
  columnClass: 'text-center',
}, {
  id: 'msg',
  title: '备注',
  type: 'string',
  columnClass: 'text-left',
}, {
  id: 'operation',
  title: '操作',
  width: 70,
  type: 'string',
  columnClass: 'text-center',
  resolution: function (value, record, column, grid, dataNo, columnNo) {
    var content = '';
    content += '<button class="btn btn-xs btn-primary" onclick="selprice(' + record.id + ');"><i class="icon-eye-open"></i>  查看</button>';
    // content += '  ';
    // content += '<button class="btn btn-xs btn-danger" onclick="del(' + record.id + ');"><i class="fa fa-trash-o"></i>  删除</button>';
    return content;
  }
}];
var priceOption = {
  lang: 'zh-cn',
  ajaxLoad: false,
  // loadURL:'url',
  exportFileName: '采购比价单列表信息',
  datas: [{
    no: '1',
    list: '硬件',
    type: '笔记本',
    name: '华硕办公笔记本',
    nmsg: 'i5CPU 8G内存 256内存',
    size: '12',
    price: '￥2222.99元',
    msg: '备注测试数据',
  }, ],
  columns: priceColumns,
  gridContainer: 'priceContainer',
  toolbarContainer: 'priceToolBarContainer',
  tools: '',
  pageSize: 10,
  pageSizeLimit: [10, 15, 20]
};
var priceGrid = $.fn.dlshouwen.grid.init(priceOption);
$(function () {
  priceGrid.load();
});

// 供应商列表
var supplier03Columns = [{
  id: 'no',
  title: '序号',
  width: 50,
  type: 'string',
  columnClass: 'text-center',
},  {
  id: 'p1',
  title: '地点',
  width: 74,
  type: 'string',
  columnClass: 'text-center',
  hideType:'lg|md|sm|xs',
}, {
  id: 'pl1',
  title: '类目',
  width: 74,
  type: 'string',
  columnClass: 'text-center',
  hideType:'lg|md|sm|xs',
},{
  id: 'pl2',
  title: '类别',
  width: 74,
  type: 'string',
  columnClass: 'text-center',
  hideType:'lg|md|sm|xs',
},{
  id: 'plname',
  title: '名称',
  width: 74,
  type: 'string',
  columnClass: 'text-center',
},{
  id: 'p2',
  title: '供应商名称',
  // width: 100,
  type: 'string',
  columnClass: 'text-center',
}, {
  id: 'p3',
  title: '联系方式',
  width: 100,
  type: 'string',
  columnClass: 'text-center',
}, 
{
  id: 'p4',
  title: '规格(参数)',
  width: 100,
  type: 'string',
  columnClass: 'text-left',
  hideType:'lg|md|sm|xs',
}, 
{
  id: 'p5',
  title: '价格(说明)',
  // width: 120,
  type: 'string',
  columnClass: 'text-center',
}, {
  id: 'p6',
  title: '价格(含税)',
  width: 150,
  type: 'string',
  columnClass: 'text-center',
},{
  id: 'pyz',
  title: '申请用印',
  width: 74,
  type: 'string',
  columnClass: 'text-center',
}, {
  id: 'p7',
  title: '交货期',
  width: 80,
  type: 'string',
  columnClass: 'text-left',
  hideType:'lg|md|sm|xs',
}, {
  id: 'p8',
  title: '质保期',
  width: 74,
  type: 'string',
  columnClass: 'text-left',
  hideType:'lg|md|sm|xs',
}, {
  id: 'p9',
  title: '付款方式',
  width: 100,
  type: 'string',
  columnClass: 'text-left',
  hideType:'lg|md|sm|xs',
}, 
{
  id: 'p10',
  title: '优劣势',
  type: 'string',
  columnClass: 'text-left',
  hideType:'lg|md|sm|xs',
}, {
  id: 'operation',
  title: '操作',
  width: 130,
  type: 'string',
  columnClass: 'text-center',
  resolution: function (value, record, column, grid, dataNo, columnNo) {
    var content = '';
    content += '<button class="btn btn-xs btn-info" onclick="pDowload('+ record.id +')"><i class="icon-cloud-download"></i>  附件</button>';
    content += '  ';
    content += '<button class="btn btn-xs btn-info" onclick="pDowload('+ record.id +')"><i class="icon-cloud-download"></i>  协议</button>';
    // content += '  ';
    // content += '<button class="btn btn-xs btn-info" onclick="shgs();"><i class="icon-plus"></i>  报价</button>';
    return content;
  }
}];
var supplier03Option = {
  lang: 'zh-cn',
  ajaxLoad: false,
  // loadURL:'url',
  exportFileName: '供应商列表',
  datas: [{
    id: 2,
    no: '1',
    pl1: '硬件',
    pl2: '笔记本',
    plname: '华硕办公笔记本',
    p1: '南京',
    p2: '南京市创瑞丰系统集成有限公司',
    p3: '12345678901',
    p4: '规格(参数)测试数据',
    p5: '单价：1450元/块，数量：10块',
    p6: '￥999,999,999.00元',
    pyz: '是',
    p7: '5个工作日',
    p8: '三年质保',
    p9:'票到60天付款',
    p10: '该供应商为我司长期合作供应商，一直为我司提供浪潮服务器及其配件，质量相对有保障，且价格相对其他两家较低。'
  }, {
    id: 2,
    no: '2',
    pl1: '硬件',
    pl2: '服务器',
    plname: '浪潮服务器',
    p1: '南京',
    p2: '南京市创瑞丰系统集成有限公司',
    p3: '12345678901',
    p4: '规格(参数)测试数据',
    p5: '单价：1450元/块，数量：10块',
    p6: '￥999,999,999.00元',
    pyz: '是',
    p7: '5个工作日',
    p8: '三年质保',
    p9:'票到60天付款',
    p10: '该供应商为我司长期合作供应商，一直为我司提供浪潮服务器及其配件，质量相对有保障，且价格相对其他两家较低。'
  }, ],
  columns: supplier03Columns,
  gridContainer: 'supplier03Container',
  toolbarContainer: 'supplier03ToolBarContainer',
  tools: '',
  pageSize: 10,
  pageSizeLimit: [10, 15, 20]
};
var supplier03Grid = $.fn.dlshouwen.grid.init(supplier03Option);
$(function () {
  supplier03Grid.load();
});

// 供应商报价历史库文件下载
function pDowload(id) {
  if(id == 1){
    layer.msg("抱歉，没有文件可供查看下载！");
  }else{
    //页面层
    layer.open({
      type: 1,
      skin: 'layui-layer-rim', //加上边框
      area: ['480px', 'auto'], //宽高
      title: '文件下载列表',
      content: '<div class="aper-layer">' +
        '<table class="table table-bordered" style="text-align: center;margin-bottom:0;">' +
        '<thead>' +
        '<tr><th>文件名称</th><th>版本号</th><th>上传时间</th><th>操作</th></tr>' +
        '</thead>' +
        '<tbody>' +
        '<tr><td>文件名称测试数据</td><td>v1.0</td><td>2019-02-03 13:00:21</td><td><a href="" download="">下载</a></td></tr>' +
        '</tbody>' +
        '</table>' +
        '</ul>' +
        '</div>'
    });
  }
}